package ihm;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;

@SuppressWarnings("serial")
public class AccueilResponsable extends JDialog implements ActionListener 
{

	private JPanel contentPane;
	private JMenuBar menuBar;
	private JMenu mnFichier;
	private JMenu mnConsulter;
	private ButtonGroup butGroup;
	private JRadioButton rbGererEntrainement;
	private JRadioButton rbConsulter;
	private JRadioButton rbGererMono;
	private JButton btnDeco;
	private JButton btnValider;
	private JMenuItem mniAjoutMoniteur;
	private JMenuItem mniModificationMoniteur;
	private JMenuItem mniSuppressionMoniteur;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) 
	{
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try
				{
					AccueilResponsable frame = new AccueilResponsable();
					frame.setVisible(true);
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}
	/**
	 * Create the frame.
	 */
	public AccueilResponsable() 
	{

		setBounds(100, 100, 450, 300);
				
		this.butGroup = new ButtonGroup();
		
		this.rbGererMono = new JRadioButton("Gérer les moniteurs");
		this.rbGererEntrainement = new JRadioButton("Gérer les entrainements");
		this.rbConsulter = new JRadioButton("Consulter le planning");

		this.butGroup.add(this.rbGererMono);
		this.butGroup.add(this.rbGererEntrainement);
		this.butGroup.add(this.rbConsulter);
		// ---- MENU ----
		menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		mnFichier = new JMenu("Fichier");
		menuBar.add(mnFichier);
		
		mnConsulter = new JMenu("Gérer les moniteurs");
		mnConsulter.addActionListener(this);
		menuBar.add(mnConsulter);
		
		mniAjoutMoniteur = new JMenuItem("Ajout d'un moniteur");
		mniAjoutMoniteur.addActionListener(this);
		mnConsulter.add(mniAjoutMoniteur);
		
		mniModificationMoniteur = new JMenuItem("Modification d'un moniteur");
		mniModificationMoniteur.addActionListener(this);
		mnConsulter.add(mniModificationMoniteur);
		
		mniSuppressionMoniteur = new JMenuItem("Suppression d'un moniteur");
		mniSuppressionMoniteur.addActionListener(this);
		mnConsulter.add(mniSuppressionMoniteur);
	
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
				
		// --- affichage ---
		this.rbGererMono.setBounds(100, 50, 220, 20);
		this.rbConsulter.setBounds(100, 100, 220, 20);
		this.rbGererEntrainement.setBounds(100, 150, 220, 20);
		
		contentPane.add(this.rbGererMono);
		contentPane.add(this.rbConsulter);
		contentPane.add(this.rbGererEntrainement);
				
		JLabel lblNom = new JLabel("Responsable:");
		lblNom.setBounds(10, 0, 80, 14);
		contentPane.add(lblNom);
		
		btnDeco = new JButton("D\u00E9connexion");
		btnDeco.addActionListener(this);
		btnDeco.setBounds(312, -3, 122, 23);
		contentPane.add(btnDeco);
		
		btnValider = new JButton("Suivant");
		btnValider.addActionListener(this);
		btnValider.setBounds(300, 200, 90, 20);
		contentPane.add(btnValider);
	}
	
	@Override
	public void actionPerformed(ActionEvent evt) 
	{
		//liste des moniteurs ajout / suppr et modif
		if(evt.getSource() == btnValider)
		{
			if(this.rbGererMono.isSelected())
			{
				FenetreGestionMoniteur fenetreMono;
			    fenetreMono = new FenetreGestionMoniteur();
			    
			    fenetreMono.setBounds(100, 100, 471, 313);
			    fenetreMono.setTitle("Gestion des moniteurs");
			    fenetreMono.setResizable(false);
			    fenetreMono.setLocation(200,200);
			    fenetreMono.setVisible(true);
			}
		}
		if(evt.getSource() == this.mniAjoutMoniteur)
		{
			FenetreGestionMoniteur fenetreMono;
		    fenetreMono = new FenetreGestionMoniteur();
		    
		    fenetreMono.setBounds(100, 100, 471, 313);
		    fenetreMono.setTitle("Gestion des moniteurs");
		    fenetreMono.setResizable(false);
		    fenetreMono.setLocation(200,200);
		    fenetreMono.setVisible(true);
		}
		if(evt.getSource() == this.mniModificationMoniteur)
		{
			FenetreGestionMoniteur fenetreMono;
		    fenetreMono = new FenetreGestionMoniteur();
		    
		    fenetreMono.setBounds(100, 100, 471, 313);
		    fenetreMono.setTitle("Gestion des moniteurs");
		    fenetreMono.setResizable(false);
		    fenetreMono.setLocation(200,200);
		    fenetreMono.setVisible(true);
		    
		}
		if(evt.getSource() == this.mniSuppressionMoniteur)
		{
			FenetreGestionMoniteur fenetreMono;
		    fenetreMono = new FenetreGestionMoniteur();
		    
		    fenetreMono.setBounds(100, 100, 471, 313);
		    fenetreMono.setTitle("Gestion des moniteurs");
		    fenetreMono.setResizable(false);
		    fenetreMono.setLocation(200,200);
		    fenetreMono.setVisible(true);
		}		
		//liste du planning de la semaine 
		//simple consultation - modification
		if(evt.getSource() == btnValider)
		{
			if(this.rbConsulter.isSelected())
			{
				FenetreGestionPlanning fenetrePlanning;
				fenetrePlanning = new FenetreGestionPlanning();
			    
				fenetrePlanning.setBounds(100,100,497,330);
				fenetrePlanning.setTitle("Plannings");
				fenetrePlanning.setResizable(false);
				fenetrePlanning.setLocation(200,200);
				fenetrePlanning.setVisible(true);
			}
		}
		
		
		/*liste les entrainemnts
		* ajout - modification 
		*/
		if(evt.getSource() == btnValider)
		{
			if(this.rbGererEntrainement.isSelected())
			{
				FenetreGestionEntrainement fenetreEntrainement;
				fenetreEntrainement = new FenetreGestionEntrainement();
			    
				fenetreEntrainement.setBounds(100,100,500,340);
				fenetreEntrainement.setTitle("Gestion des entrainements");
				fenetreEntrainement.setResizable(false);
				fenetreEntrainement.setLocation(200,200);
				fenetreEntrainement.setVisible(true);
			}
		}
		
		if(evt.getSource() == btnDeco)
		{
			this.setVisible(false);
			this.dispose();
			Connecter frameConnecter = new Connecter();
			frameConnecter.setVisible(true);
		}
	}
}
